#include "persistence_mt.h"

#include <fsprocesspersistenceassistant.h>
#include <fsprocesspersistentdocument.h>
#include <fsstorage.h>
#include <mimetype.h>
#include <mimetypemanager.h>
#include <persistence.h>

#include <QtCore/QDir>
#include <QtCore/QUrl>
#include <QtTest/QTest>

using namespace core;
using namespace fspersistence;
using namespace moduletest;
using namespace swp;

void Persistence_mt::initTestCase()
{
    GlobalPatternList list;
    list.append(QPair<QString, uint>("*.proc", 0));

    MimeType mimeType("name", "binary", "", list, "");
    MimeTypeManager::getInstance()->registerMimeType(mimeType);

    Persistence::initialize();

    FsStorage storage;

    Persistence::registerStorage(&storage);

    FsProcessPersistenceAssistant assistant(mimeType);

    Persistence::registerAssistant(mimeType, &assistant);

    QString path = QDir().currentPath();
    path += "/_build/debug/test.proc";

    m_document = Persistence::createDocument(QUrl::fromLocalFile(path),
        storage.registeredName());
}

void Persistence_mt::open()
{
    QVERIFY(!m_document.isNull());
}

void Persistence_mt::save()
{

}

void Persistence_mt::cleanupTestCase()
{
    Persistence::deleteDocument(m_document);

    Persistence::dispose();
}
